package br.com.meuposto.view;

import java.text.DecimalFormat;
import javax.swing.JOptionPane;
import javax.swing.UIManager;


public class PainelControle extends javax.swing.JFrame {

    private double totalCombustivel = 0;
    private double totalOleo = 0;
    //Combustíveis
    public String valorGasolina = "2.79";
    public String valorAlcool = "2.39";
    public String valorDiesel = "2.10";
    //Óleos
    public String valorGnv = "1.90";
    public String valorBr = "9.90";
    public String valorMobil = "8.59";
    public String valorCastrol = "12.99";
    
    public PainelControle() {
        initComponents();
       
        verificarCBCombustivel();
        verificarCBOleo();
        calcularTotal();
    }

    
    public String verificarCBCombustivel(){
        String valor = null;
        if(jCBCombustivel.getSelectedItem().toString() == "Gasolina"){
            valor = valorGasolina;
        }else if(jCBCombustivel.getSelectedItem().toString() == "Alcool"){
            valor = valorAlcool;
        }else if(jCBCombustivel.getSelectedItem().toString() == "Diesel"){
            valor = valorDiesel;
        }else if(jCBCombustivel.getSelectedItem().toString() == "GNV"){
            valor = valorGnv;
        }
        jTFPrecoLitro.setText(valor);
        jTFTotalCombustivel.setText(calcularTotalCombustivel());
        return valor;
    }
    private String calcularTotalCombustivel(){
       double litro = 0;
       double valorLitro = 0;
       try{
           litro = Double.parseDouble(jTFLitros.getText());
           valorLitro = Double.parseDouble(jTFPrecoLitro.getText());
           
           totalCombustivel = litro * valorLitro;
           
       }catch(NumberFormatException e){
           jTFLitros.setText("0");
       }finally{
            
        }
       DecimalFormat df = new DecimalFormat("0.##");
       return df.format(totalCombustivel);
    }
    public String verificarCBOleo(){
        String valor = "0";
        if(jCBMarca.getSelectedItem().toString() == "BR"){
            valor = valorBr;
        }else if(jCBMarca.getSelectedItem().toString() == "Mobil"){
            valor = valorMobil;
        }else if(jCBMarca.getSelectedItem().toString() == "Castrol"){
            valor = valorCastrol;
        }
        jTFPrecoFrasco.setText(valor);
        jTFTotalOleo.setText(calcularTotalOleo());
        
        return valor;
    }
    private String calcularTotalOleo(){
       double frasco = 0;
       double valorFrasco = 0;
       try{
           frasco = Double.parseDouble(jTFFrasco.getText());
           valorFrasco = Double.parseDouble(jTFPrecoFrasco.getText());
           
           totalOleo = frasco * valorFrasco;
           
       }catch(NumberFormatException e){
           jTFFrasco.setText("0");
       }finally{
            
        }
       DecimalFormat df = new DecimalFormat("0.##");
       return df.format(totalOleo);
    }
    private void calcularTotal(){
        double t = 0;
        double total = totalCombustivel + totalOleo;
        DecimalFormat df = new DecimalFormat("R$ 0.##");
        
        if(jCBTipoPagamento.getSelectedItem().toString() == "Avista"){
            t = total*0.90;
            jTFDesconto.setText("10% de desconto");
        }else if(jCBTipoPagamento.getSelectedItem().toString() == "Prazo em 30 Dias"){
            t = total;
            jTFDesconto.setText("Nenhum desconto");
        }
        else if(jCBTipoPagamento.getSelectedItem().toString() == "Prazo em + de 30 Dias"){
            t = total*1.02;
            jTFDesconto.setText("Aumento de 2%");
        }
        
        
        
        jTFTotal.setText(df.format(total));
        jTFTotalComDesconto.setText(df.format(t));
    }
    private void apagarCampos(){
        jTFTotalCombustivel.setText("0");
        jTFTotalOleo.setText("0");
        jTFLitros.setText("0");
        jTFFrasco.setText("0");
    }
    
    
    
    
    
    

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPHead = new javax.swing.JPanel();
        jLTítulo = new javax.swing.JLabel();
        jToolBar1 = new javax.swing.JToolBar();
        jBCombustivel = new javax.swing.JButton();
        jBOleo = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jCBCombustivel = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jTFLitros = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTFPrecoLitro = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jTFTotalCombustivel = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jCBMarca = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jTFFrasco = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jTFPrecoFrasco = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTFTotalOleo = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jCBTipoPagamento = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jTFTotalComDesconto = new javax.swing.JTextField();
        jBCalcular = new javax.swing.JButton();
        jTFDesconto = new javax.swing.JTextField();
        jTFTotal = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Posto de Combustível");
        setResizable(false);

        jPHead.setBackground(new java.awt.Color(255, 255, 255));

        jLTítulo.setBackground(new java.awt.Color(102, 102, 102));
        jLTítulo.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        jLTítulo.setForeground(new java.awt.Color(255, 0, 0));
        jLTítulo.setText("POSTO DE COMBUSTÍVEL");

        javax.swing.GroupLayout jPHeadLayout = new javax.swing.GroupLayout(jPHead);
        jPHead.setLayout(jPHeadLayout);
        jPHeadLayout.setHorizontalGroup(
            jPHeadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPHeadLayout.createSequentialGroup()
                .addGap(47, 47, 47)
                .addComponent(jLTítulo)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPHeadLayout.setVerticalGroup(
            jPHeadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPHeadLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLTítulo)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jToolBar1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jToolBar1.setRollover(true);

        jBCombustivel.setText("Combustível");
        jBCombustivel.setFocusable(false);
        jBCombustivel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBCombustivel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBCombustivel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCombustivelActionPerformed(evt);
            }
        });
        jToolBar1.add(jBCombustivel);

        jBOleo.setText("Óleo");
        jBOleo.setFocusable(false);
        jBOleo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBOleo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBOleo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBOleoActionPerformed(evt);
            }
        });
        jToolBar1.add(jBOleo);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "COMBUSTÍVEL", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), new java.awt.Color(255, 51, 51))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel1.setText("Combustível :");

        jCBCombustivel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jCBCombustivel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Gasolina", "Alcool", "Diesel", "GNV" }));
        jCBCombustivel.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jCBCombustivelItemStateChanged(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel2.setText("Litros :");

        jTFLitros.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTFLitros.setText("0");
        jTFLitros.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTFLitrosKeyReleased(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel3.setText("L");

        jLabel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel4.setText("Preço do Litro :");

        jTFPrecoLitro.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jTFPrecoLitro.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTFPrecoLitro.setEnabled(false);

        jLabel5.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel5.setText("TOTAL :");

        jTFTotalCombustivel.setEditable(false);
        jTFTotalCombustivel.setBackground(new java.awt.Color(255, 255, 245));
        jTFTotalCombustivel.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        jTFTotalCombustivel.setForeground(new java.awt.Color(0, 102, 102));
        jTFTotalCombustivel.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCBCombustivel, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTFLitros, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTFPrecoLitro, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTFTotalCombustivel)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jCBCombustivel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(jTFLitros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTFPrecoLitro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jTFTotalCombustivel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "TROCA DE ÓLEO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), new java.awt.Color(255, 51, 51))); // NOI18N

        jLabel6.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel6.setText("Marca :");

        jCBMarca.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jCBMarca.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "BR", "Mobil", "Castrol" }));
        jCBMarca.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jCBMarcaItemStateChanged(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel7.setText("Frasco :");

        jTFFrasco.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTFFrasco.setText("0");
        jTFFrasco.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTFFrascoKeyReleased(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel8.setText("L");

        jLabel9.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel9.setText("Preço do Frasco :");

        jTFPrecoFrasco.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jTFPrecoFrasco.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTFPrecoFrasco.setEnabled(false);

        jLabel10.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel10.setText("TOTAL :");

        jTFTotalOleo.setEditable(false);
        jTFTotalOleo.setBackground(new java.awt.Color(255, 255, 245));
        jTFTotalOleo.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        jTFTotalOleo.setForeground(new java.awt.Color(0, 102, 102));
        jTFTotalOleo.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCBMarca, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTFFrasco, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel8)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTFPrecoFrasco, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTFTotalOleo)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jCBMarca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jTFFrasco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTFPrecoFrasco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jTFTotalOleo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        jLabel11.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel11.setText("Forma de Pagamento :");

        jCBTipoPagamento.setFont(new java.awt.Font("Arial", 0, 9)); // NOI18N
        jCBTipoPagamento.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Avista", "Prazo em 30 Dias", "Prazo em + de 30 Dias" }));
        jCBTipoPagamento.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jCBTipoPagamentoItemStateChanged(evt);
            }
        });

        jLabel12.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel12.setText("Total :");

        jTFTotalComDesconto.setEditable(false);
        jTFTotalComDesconto.setBackground(new java.awt.Color(255, 255, 245));
        jTFTotalComDesconto.setFont(new java.awt.Font("Arial", 1, 36)); // NOI18N
        jTFTotalComDesconto.setForeground(new java.awt.Color(0, 102, 102));
        jTFTotalComDesconto.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTFTotalComDesconto.setText("R$ 0,00");

        jBCalcular.setText("Calcular");
        jBCalcular.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCalcularActionPerformed(evt);
            }
        });

        jTFDesconto.setBackground(new java.awt.Color(204, 204, 204));
        jTFDesconto.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        jTFDesconto.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        jTFTotal.setEditable(false);
        jTFTotal.setBackground(new java.awt.Color(255, 255, 255));
        jTFTotal.setFont(new java.awt.Font("Arial", 1, 11)); // NOI18N
        jTFTotal.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPHead, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jCBTipoPagamento, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jTFDesconto, javax.swing.GroupLayout.Alignment.LEADING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTFTotalComDesconto)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTFTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap())
            .addComponent(jBCalcular, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPHead, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12)
                    .addComponent(jTFTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTFTotalComDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jCBTipoPagamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTFDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBCalcular, javax.swing.GroupLayout.DEFAULT_SIZE, 39, Short.MAX_VALUE))
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void jCBCombustivelItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCBCombustivelItemStateChanged
        jTFPrecoLitro.setText(verificarCBCombustivel());
    }//GEN-LAST:event_jCBCombustivelItemStateChanged

    private void jCBMarcaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCBMarcaItemStateChanged
        
        jTFPrecoFrasco.setText(verificarCBOleo());
    }//GEN-LAST:event_jCBMarcaItemStateChanged

    private void jTFLitrosKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTFLitrosKeyReleased
         jTFTotalCombustivel.setText(calcularTotalCombustivel());
    }//GEN-LAST:event_jTFLitrosKeyReleased

    private void jTFFrascoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTFFrascoKeyReleased
        jTFTotalOleo.setText(calcularTotalOleo());
               
    }//GEN-LAST:event_jTFFrascoKeyReleased

    private void jBCalcularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCalcularActionPerformed
        calcularTotal();
        apagarCampos();
    }//GEN-LAST:event_jBCalcularActionPerformed

    private void jCBTipoPagamentoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCBTipoPagamentoItemStateChanged
        calcularTotal();
    }//GEN-LAST:event_jCBTipoPagamentoItemStateChanged

    private void jBCombustivelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCombustivelActionPerformed
        new Combustivel(PainelControle.this).setVisible(true);
    }//GEN-LAST:event_jBCombustivelActionPerformed

    private void jBOleoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBOleoActionPerformed
        new Oleo(PainelControle.this).setVisible(true);
    }//GEN-LAST:event_jBOleoActionPerformed

   

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBCalcular;
    private javax.swing.JButton jBCombustivel;
    private javax.swing.JButton jBOleo;
    private javax.swing.JComboBox jCBCombustivel;
    private javax.swing.JComboBox jCBMarca;
    private javax.swing.JComboBox jCBTipoPagamento;
    private javax.swing.JLabel jLTítulo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPHead;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField jTFDesconto;
    private javax.swing.JTextField jTFFrasco;
    private javax.swing.JTextField jTFLitros;
    private javax.swing.JTextField jTFPrecoFrasco;
    private javax.swing.JTextField jTFPrecoLitro;
    private javax.swing.JTextField jTFTotal;
    private javax.swing.JTextField jTFTotalComDesconto;
    private javax.swing.JTextField jTFTotalCombustivel;
    private javax.swing.JTextField jTFTotalOleo;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables
}
